home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Linux Cubed Series 8: LINUX Games
/
Linux Cubed Series 8 - LINUX Games.iso
/
games
/
muds
/
pennmush.000
/
pennmush-1.50-p8-linux.tar
/
pennmush
/
bigrams.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-03-25
|
924b
|
52 lines
/* bigrams.c */
/* This is taken, with permission, from the UnterMUD code. */
#include <stdio.h>
#include <ctype.h>
/* this code is not pretty, nor does it have to be */
/* run as:
* zcat database.Z | bigrams | sort -n -r | head -128
* will give the 128 most used bigrams in the db. then edit bigrams.h
*/
main()
{
int counts[256][256];
int last;
int c;
int nhigh = 0;
int highest = 0;
int lowest = 0;
for(c = 0; c < 255; c++)
for(last = 0; last < 255; last++)
if(!isprint(c) || !isprint(last))
counts[c][last] = -1;
else
counts[c][last] = 0;
while(1) {
c = getchar();
if(feof(stdin))
break;
if(last == -1 || c == '\n') {
if(c != '\n')
last = c;
continue;
}
if(counts[last][c] != -1)
counts[last][c]++;
last = c;
}
for(c = 0; c < 255; c++)
for(last = 0; last < 255; last++)
if(counts[c][last] > 0)
printf("%d \"%c%c\"\n",counts[c][last],c,last);
}